//
//  main.m
//  gh
//
//  Created by likexian on 16-5-9.
//  Copyright (c) 2016年 OYZH. All rights reserved.
//
#import <Foundation/Foundation.h>
        
        int main(int argc, const char * argv[])
        {
            
            @autoreleasepool {
                
                // insert code here...
                NSLog(@"Hello, World!");
                NSString *path=@"/Users/mac1/Desktop/00001.vcf";
                NSError *err;
                NSString *vcf=[[NSString alloc]initWithContentsOfFile:path encoding:NSUTF8StringEncoding error:&err];
                NSArray *arr=[vcf componentsSeparatedByString:@"\n"];
                for(NSString *line in arr){
                    if ([line hasPrefix:@"BEGIN"]) {
                        NSLog(@"打开一条新的记录");
                    }
                    if ([line hasPrefix:@"END"]) {
                        NSLog(@"这条记录结束了");
                    }
                    if ([line hasPrefix:@"TEL"]) {
                        NSLog(@"找到一条电话记录%@",line);
                        NSArray *tels=[line componentsSeparatedByString:@";"];
                        NSString *last=tels.lastObject;
                        last=[last substringFromIndex:5];
                        NSLog(@"tels:%@",last);
                    }
                    if ([line hasPrefix:@"FN"]) {
                        NSLog(@"找到一条FN,也就是姓名%@",line);
                        NSArray *tel=[line componentsSeparatedByString:@":"];
                        NSString *str=tel.lastObject;
                        str=[str stringByReplacingOccurrencesOfString:@"=" withString:@"%"];
                        str=str.stringByRemovingPercentEncoding;
                        NSLog(@"姓名:%@",str);
                        
                    }
                }
                
            }
            return 0;
        }
        
        

